﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Rüdiger_Baustein4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();



        }
        private void btStart_Click(object sender, EventArgs e)
        {   string strName = tBoxName.Text;
            if (strName == "Glados")
            {
                tBoxAus.Text = "Du hast mir nichts zu befehlen, bei Menschen ist sowieso alles falsch.";

            }
            else
            {
                bool A, B, C, D;
                bool b;
                A = cBoxWertA.Checked; B = cBoxWertB.Checked; C = cBoxWertC.Checked; D = cBoxWertD.Checked;
                b = SchaltNetz(A, B, C, D);
                tBoxAus.Text += "A= " + A.ToString() + "B= " + B.ToString() + "C= " + C.ToString() + "D= " + D.ToString()
                                  + "-->"+ b+"\r\n";


















                /*
                
                cUnd Baustein1 = new cUnd(3, "1.");
                cUnd Baustein2 = new cUnd(2, "2");
                Baustein2.invert(1);
                cUnd Baustein3 = new cUnd(3, "3");
                Baustein3.invert(2);
                cUnd Baustein4 = new cUnd(2, "4");
                cOder Baustein5 = new cOder(4, "Gesamt");
                if (cBoxWertA.Checked == true)
                {

                }
                Baustein5.BEingaenge[1] = Baustein1.BAus;
                Baustein5.BEingaenge[2] = Baustein2.BAus;
                Baustein5.BEingaenge[3] = Baustein3.BAus;
                Baustein5.BEingaenge[4] = Baustein4.BAus;
                tBoxAus.Text = Baustein5.report();
            */}
        }

        private bool SchaltNetz(bool A, bool B, bool C, bool D)
        {//F=A*B*C+AD+ABC+AB
            cUnd Baustein1 = new cUnd(3, "1.");
            Baustein1.set(0, A);
            Baustein1.set(1,B);
            Baustein1.set(2, C);  
            Baustein1.calc();          
            cUnd Baustein2 = new cUnd(2, "2");
            Baustein2.invert(1);
            Baustein2.set(0, A);
            Baustein2.set(1, D);
            Baustein2.calc();
            cUnd Baustein3 = new cUnd(3, "3");
            Baustein3.invert(2);
            Baustein3.set(0, A);
            Baustein3.set(1, B);
            Baustein3.set(2, C);
            Baustein3.calc();
            cUnd Baustein4 = new cUnd(2, "4");
            Baustein4.set(0, A);
            Baustein4.set(1, B);
            Baustein4.calc();
            cOder Baustein5 = new cOder(4, "Gesamt");
              
            Baustein5.set(0,Baustein1.BAus);
            Baustein5.set(1, Baustein2.BAus);
            Baustein5.set(2, Baustein3.BAus);
            Baustein5.set(3, Baustein4.BAus);
            Baustein5.calc();
            return Baustein5.BAus;
        }
    }
}